import styles from './index.less'
import { Switch } from 'antd'
import { useEffect } from 'react'
import request from '@/utils/reques'


export default function IndexPage() {


  // umi-request异步请求
  useEffect(() => {
    request('/api/users').then((res: any) => {
      console.log(res);
    })
  }, [])


  // umi-request同步请求
  useEffect(() => {
    const data = async () => {
      await request('/api/users').then((res: any) => {
        console.log(res);
      })
    }
    data()
  }, [])

  // umi-request请求带参数
  useEffect(() => {
    request('/api/users/create', {
      method: 'post',
      params: {
        name: 1,
      },
      // skipErrorHandler:true 是会跳过默认的错误处理
      skipErrorHandler: true,
    }).then((res: any) => {
      console.log(res);
    })
  }, [])

  return (
    <div>
      <h1 className={styles.title}>HOME</h1>
    </div>
  );
}
